/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package passwordchecker;

/**
 *
 * @author Daniel
 */
public class PasswordChecker01 extends retornaForca {

    public void checkPassword(String passwd) {

        int is = 0;
        int cont;
        int contSimbs = 0;
        String text = "";
        boolean lower;
        boolean upper;
        boolean number;

        lower = temMinuscula(passwd);
        upper = temMaiuscula(passwd);
        number = temNumero(passwd);

        cont = countNum(passwd);

        //usar vetores
        int tamanho[] = {5, 8, 16, Integer.MAX_VALUE};
        int strength[] = {3, 6, 12, 18};

        for (int i = 0; i < tamanho.length; i++) {
            if (is < tamanho[i]) {
                is = is + strength[i];
                text = text + String.valueOf(strength[i]) + " points for length (" + passwd.length() + ")\n";
                break;
            }
        }
        if (lower) {
            is = (is + 1);
            text = text + "1 point for at least one lower case char\n";

        }

        if (upper) {
            is = (is + 5);
            text = text + "5 points for at least one upper case char\n";
        }


        if (number) {
            is = (is + 5);
            text = text + "5 points for at least one number\n";

        }

        if (cont >= 3) {
            is = (is + 5);
            text = text + "5 points for at least three numbers\n";
        }

        contSimbs = contSimb(passwd, contSimbs);

        if (contSimbs >= 1) {
            is = (is + 5);
            text = text + "5 points for at least one special char\n";
        }

        if (contSimbs >= 2) {
            is = (is + 5);
            text = text + "5 points for at least two special chars\n";
        }

        if (lower && upper) {
            is = (is + 2);
            text = text + "2 combo points for upper and lower letters\n";
        }
        if ((lower || upper) && number) {
            is = (is + 2);
            text = text + "2 combo points for letters and numbers\n";
        }

        if ((cont > 0 || lower || upper) && contSimbs > 0) {
            is = (is + 2);
            text = text + "2 combo points for (letters or numbers) and special chars\n";
        }

        analisaForca(is);

        System.out.println("Strength score is: " + is);
        System.out.println("Log: " + text);
    }
}